-
-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TouchID Implementation [iOS Sim Only] #509
Conversation
Tests were failing because of an indentation problem in IOSGesturesTest.java and because a static import in XCUIAutomationTest.java was coming after the rest of the imports instead of before
(See https://support.apple.com/en-ca/HT201371 for description of the Touch ID feature) This endpoint simulates the TouchID feature.
*Not sure why the README.md was diffed that way. I only added one line under the 'Added Functions' header |
@@ -31,8 +34,6 @@ | |||
|
|||
import java.io.File; | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
|
|||
public class XCUIAutomationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpgraham Can you add some tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the test. It doesn't do any assertions because there isn't anything to check, it just calls the methods to verify that there aren't any exceptions.
/** | ||
* This method forms a {@link java.util.Map} of parameters for the touchId simulator | ||
* | ||
* @param match Are we simulating a successful fingerprint scan? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it a question here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's how I've documented boolean parameters in the past. I'll change it to be more in line with how it's normally documented.
* | ||
* @param match Are we simulating a successful fingerprint scan? | ||
*/ | ||
default void touchId(boolean match) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add in doc as it is Simulator only?
- endTestCoverage() | ||
- isLocked() | ||
- shake() | ||
- touchId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this change? We will apply this change post release.
This will be added post release
This test only executes the driver.touchId method, it doesn't do any assertions. Just verifies that it doesn't throw any exceptions.
Thanks @SrinivasanTarget, I made the changes you requested. If you could review them and they're good let me know so that I can squash the changes and merge them. |
driver.touchId(false); | ||
assertEquals(true, true); | ||
} catch(Exception e){ | ||
assertEquals(true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpgraham I think it is more senseful to throw an exception.
Otherwice we have a risk to produce and invalid build or to not react to server changes.
@@ -56,5 +57,14 @@ default void hideKeyboard(String strategy, String keyName) { | |||
default void shake() { | |||
CommandExecutionHelper.execute(this, shakeCommand()); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am against the adding to the IOSDeviceActionShortcuts
. This interface is going to be deprecated. Please take a look at this working branch. IOSDeviceActionShortcuts is going to be deprecated.
It is better to add such interface:
package io.appium.java_client.ios;
public interface ChecksTouchId extends ExecutesMethod {
/**
* Simulate touchId event
*
* @param match If true, simulates a successful fingerprint scan. If false, simulates a failed fingerprint scan
*/
default void touchId(boolean match) {
CommandExecutionHelper.execute(this, touchIdCommand(match));
}
}
and make IOSDriver implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the input Sergey. I made the change.
@dpgraham |
try { | ||
driver.touchId(true); | ||
driver.touchId(false); | ||
assertEquals(true, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual Usecase of API touchID
is to unlock or sign in to any application using touchID. Since we dont have our test app built with any registration or sign in feature, we cannot use that scenario.
Otherwise Can we lock the simulator and unlock the simulator using driver.touchID(true)
.Ideal case this should be working fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So test scenario should be something like,
try {
driver.lockDevice(2);
driver.touchId(true);
} catch (Exception e) {
assertTrue(false);
}
/** | ||
* Simulate touchId event | ||
* | ||
* @param match If true, simulates a successful fingerprint scan. If false, simulates a failed fingerprint scan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i'm not wrong, this will fail as per google style each doc line should end with a period.
@dpgraham I've reviewed again now. Please take a look. |
Tests were failing because of an indentation problem in IOSGesturesTest.java and because a static import in XCUIAutomationTest.java was coming after the rest of the imports instead of before
(See https://support.apple.com/en-ca/HT201371 for description of the Touch ID feature) This endpoint simulates the TouchID feature.
This will be added post release
This test only executes the driver.touchId method, it doesn't do any assertions. Just verifies that it doesn't throw any exceptions.
-Moved touchID out of IOSDeviceActionShorcuts and into PerformsTouchID -Made IOSDriver implement PerformsTouchID -Fixed typo that I noticed in CommandExecutionHelper -Fixed linting errors
I've updated the code again |
driver.performTouchID(false); | ||
assertEquals(true, true); | ||
} catch (Exception e) { | ||
assertEquals(true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test should throw the exception.
At least you can do that
try {
//do something
//assert the result
} catch (Exception e) {
throw e;
} finally {
//attemt to stabilize the simulator
//or something else
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpgraham Can you update tests here as suggested please?
/** | ||
* This method forms a {@link java.util.Map} of parameters for the touchId simulator | ||
* | ||
* @param match If true, simulates a successful fingerprint scan. If false, simulates a failed fingerprint scan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc should end with a period everywhere.
Changes made |
@dpgraham Everuthing is ok for me. But could you please improve the proposed test the way I have asked? |
Change list
Added touchId command
Types of changes
What types of changes are you proposing/introducing to Java client?
Details
Touch ID is a feature in Apple products (see https://support.apple.com/en-ca/HT201371). This endpoint simulates the behaviour.